import {fromJS} from "immutable";
import {constants} from "./index";

const defaultState = fromJS({
    topicList: [],
    articleList: [],
    recommendList: [],
    articlePage: 1,
    showScroll: false
})
const reducer = (state = defaultState, action) => {
    switch (action.type) {
        case constants.CHANGE_HOME_DATA:
            return state.merge({
                topicList: fromJS(action.topicList),
                articleList: fromJS(action.articleList),
                recommendList: fromJS(action.recommendList)
            })
        case constants.ADD_ARTICLE_LIST:
            // return state.set('articleList', state.get('articleList').concat(action.list)).set('articlePage', action.page);
            return state.merge({
                'articleList': state.get('articleList').concat(action.list),
                'articlePage': action.page
            })
        case constants.TOGGLE_SCROLL_TOP:
            console.log(action.show)
            return state.set('showScroll', action.show);
        default:
            return state;
    }
};
export default reducer;